package com.hejia.alauda.entity;

import javax.persistence.Column;
import java.util.Date;

/**
 * 积分的操作记录（何时获取了多少，何时用掉了多少等）
 *
 * @author paul
 */
public class CreditOperation extends BaseEntity {

	/**
     *
     */
	private static final long serialVersionUID = 3843013621748476663L;

	@Column
	private User user;

	@Column
	private Integer creditChanges;// 积分变动 正数收入积分 负数为支出积分

	@Column
	private Operation operation; // 积分变动操作（比如注册，购买，代替现金等）

	@Column
	private String description;// 具体描述

	public CreditOperation() {
		super();
		setModifyDate(new Date());
	}

	public User getUser() {
		return user;
	}

	public void setUser(User user) {
		this.user = user;
	}

	public Integer getCreditChanges() {
		return creditChanges;
	}

	public void setCreditChanges(Integer creditChanges) {
		this.creditChanges = creditChanges;
	}

	public Operation getOperation() {
		return operation;
	}

	public void setOperation(Operation operation) {
		this.operation = operation;
	}

	public String getDescription() {
		return description;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	public String getOperationText() {
		if (getOperation() == null) {
			return "未操作";
		}
		String str = "";
		switch (getOperation()) {
		case BIND:
			str = "绑卡";
			break;
		case INVITEE_BUY:
			str = "被邀请人第一次购买";
			break;
		case LOGIN:
			str = "登录送积分";
			break;
		case REGISTER:
			str = "注册送积分";
			break;
		case BUY:
			str = "购买产品送积分";
			break;
		case CONSUME:
			str = "积分消费";
			break;
		case ROLLBACK:
			str = "积分兑换失败返还";
			break;
		case INVITE:
			str = "邀请送积分";
			break;
		case MANUAL:
			str = "人工送积分";
			break;
		}
		return str;
	}

	/**
	 * 获得/支出积分类型 LOGIN 登录获得积分 REGISTER 注册获得积分 BUY 购买产品获得积分 ROLLBACK 积分兑换出错回滚
	 *
	 * @author paul
	 */
	public static enum Operation {
		YICHE_2015,
		FLASH_SALE,//限时抢购的赠送的积分
		FLASH_SALE_BONUS,//限时抢购的抽奖的积分
		BIND, // 绑卡
		INVITEE_BUY, // 被邀请人第一次购买
		LOGIN, // 登录送积分
		REGISTER, // 注册送积分
		BUY, // 购买产品送积分
		CONSUME, // 积分消费
		ROLLBACK, // 积分兑换失败返还
		INVITE, // 邀请送积分
		MANUAL;// 人工送积分
	}
}
